package cn.com.lyj6851.user.controller;

import java.util.UUID;

import org.springframework.http.ResponseEntity;
import org.springframework.http.ResponseEntity.BodyBuilder;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.com.lyj6851.common.util.BeanValidator;
import cn.com.lyj6851.user.entity.RoleMenu;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 〈功能简述〉<br>
 * 〈角色菜单〉
 *
 */
@RestController
@Api(tags = "角色菜单中间表")
public class RoleMenuController {

	@PostMapping("rolemenu")
    @ApiOperation(value = "新增")
    public BodyBuilder add(RoleMenu roleMenu) {
		BeanValidator.check(roleMenu);
        roleMenu.setId(UUID.randomUUID().toString());
        roleMenu.insert();
        return ResponseEntity.ok();
    }

    @DeleteMapping("rolemenu")
    @ApiOperation(value = "删除")
    public BodyBuilder delete(RoleMenu roleMenu) {
        roleMenu.deleteById();
        return ResponseEntity.ok();
    }

    @PutMapping("rolemenu")
    @ApiOperation(value = "修改")
    public BodyBuilder update(RoleMenu roleMenu){
    	BeanValidator.check(roleMenu);
        roleMenu.updateById();
        return ResponseEntity.ok();
    }
}
